package com.dmap.analysispoint.controller.api;

import com.dmap.analysispoint.po.BurialPoint;
import com.dmap.analysispoint.service.AddBurialPointInfoService;
import com.dmap.base.constants.Constant;
import com.dmap.base.vo.BaseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * \* @author:zhouhao
 * \* Date:03/07/2018
 * \* Description:
 * \*
 */
@Api(value = "插入埋点信息V2", description = "api/插入埋点信息V2")
@Controller
@RequestMapping(value = "/api/dmap-analysis-point-server/v2/")

public class BurialPointV2Controller {

    @Resource
    private AddBurialPointInfoService addBurialPointInfoService;

    @ResponseBody
    @ApiOperation(value = "插入基础的埋点信息",
            notes = "1.传入所要查询的参数，其中用户ID、手机唯一标识、渠道、项目编号、app版本号、数据上报时间、用户类型必传\n" +
                    "2.返回插入的记录条数")
    @RequestMapping(value = "insertBaseBurialPointInfoV2", method = RequestMethod.POST)
    public BaseVo insertBaseBurialPointInfoV2(@RequestBody List<BurialPoint> param) {
        BaseVo baseVo = new BaseVo();
        if (param == null) {
            baseVo.setCode(Constant.RESPONSE_PARAM_ERROR_CODE);
            baseVo.setMsg(Constant.RESPONSE_PARAM_ERROR_MSG);
        }
        int success = addBurialPointInfoService.insertBaseBurialPointInfo(param);
        if (success == 0) {
            baseVo.setCode(Constant.RESPONSE_INSERT_ERROR_CODE);
            baseVo.setMsg(Constant.RESPONSE_INSERT_ERROR_MSG);
        }
        baseVo.setData(success);
        return baseVo;
    }
}